<include file="Public:header" />
<div class="wrapper wrapper-content ">
	<include file="Public:alert" />
    <div class="row">
        <div class="col-md-12">
            <div class="ibox float-e-margins">
				<div class="title-bar" style="">
					<div class="row" id="title-show">
						<ul class="nav pull-left" style="margin:0px 10px 0px 20px;">
							<span><img src="__PUBLIC__/img/receive_view_icon.png" style="margin-bottom:9px;" alt=""></span><span style="font-size:21px;margin-left:5px">&nbsp;&nbsp;&nbsp;{$info.name}</span>&nbsp;&nbsp; 
						</ul>
						<a href="{:U('finance/edit','t=payables&id='.$info['payables_id'])}" class="btn btn-outline btn-default pull-right" style="margin-right: 15px;"><i class="fa fa-pencil"></i>&nbsp;&nbsp;编辑</a>&nbsp;&nbsp; 
					</div>
				</div>
				<div class="tabs-container" >
					<div class="pull-left col-sm-7" style="padding-left:0px;">
						<div style="border:1px solid #ccc;background:#fff;" id="left-content">
							<div class="tab-content" >
								<div class="tab-pane in active " id="tab1">
									<div class="panel-body ">
										<div style="font-size:13px;font-weight:700;margin-top:15px;"><span style="border-left:8px solid #19AA8D;padding-left:16px;height:10px;"></span>基本信息</div>
										<div class="form-horizontal view-group " style="margin-top:15px;padding-bottom:50px;">
											<div class="form-group">
												<label class="col-lg-2 control-label">应付款编号</label>
												<div class="col-lg-4">
													<p class="form-p">
														{$info['name']}
													</p>
												</div>
												<label class="col-lg-2 control-label">应付款金额</label>
												<div class="col-lg-4">
													<p class="form-p">
														{$info['price']}
													</p>
												</div>
											</div>
											<div class="form-group">
												<label class="col-lg-2 control-label">应付款类型</label>
												<div class="col-lg-4">
													<p class="form-p">
														{$info['type_name']}
													</p>
												</div>
												<label class="col-lg-2 control-label">相关客户</label>
												<div class="col-lg-4">
													<p class="form-p">
														<a target="_blank" href="{:U('customer/view','id='.$info['customer_id'])}">{$info['customer_name']}</a>
													</p>
												</div>
											</div>
											<div class="form-group">
												<label class="col-lg-2 control-label">{:L('RECEIVING TIME')}</label>
												<div class="col-lg-4">
													<p class="form-p">
														<if condition="$info['pay_time']">{$info['pay_time']|date="Y-m-d",###}</if>
													</p>
												</div>
												<label class="col-lg-2 control-label">付款人</label>
												<div class="col-lg-4">
													<p class="form-p">
														<a class="role_info" rel="{$info['owner_role_id']}" href="javascript:void(0)">{$info['owner_name']}</a>
													</p>
												</div>
											</div>
											<div class="form-group">
												<label class="col-lg-2 control-label">{:L('CREATOR_ROLE')}</label>
												<div class="col-lg-4">
													<p class="form-p">
														<a class="role_info" rel="{$info['creator_role_id']}" href="javascript:void(0)">{$info['creator_name']}</a>
													</p>
												</div>
												<label class="col-lg-2 control-label">{:L('CREATE_TIME')}</label>
												<div class="col-lg-4">
													<p class="form-p">
														{$info['create_time']|date="Y-m-d",###}
													</p>
												</div>
											</div>
											<div class="form-group">
												<label class="col-lg-2 control-label">{:L('DESCRIPTION')}</label>
												<div class="col-lg-10">
													<span style="padding-top:15px;">
														{$info.description}
													</span>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="pull-right col-sm-5" style="background:#fff;margin-left:0px;border:1px solid #ccc;" id="right-content">
						<div style="margin:20px 15px 0 15px;height:35px;border-bottom: 1px solid #e7eaec;">
							<i style="font-size:18px;padding-left:10px;margin-top:2px;color:#B4B1C2" class="fa fa-cny"></i>
							<span style="padding:10px 20px 5px 10px;font-size:16px;">付款</span>
							<a href="javascript:void(0);" class="pull-right" id="add_paymentorder" style="padding-right:20px;"><i class="fa fa-plus" style="font-size:18px;color:#B4B1C2"></i></a>
						</div>
						<div class="back_box bg_border" style="padding:15px;">
							<div style="font-size:16px;margin-bottom:10px;">合计：{:number_format($info['price'],2)}元 / <span style="color:#FB8C57">未付款:  {:number_format($info['un_payment'],2)}元</span></div>
							<table class="table">
								<thead>
									<tr style="background-color:#F5F5F6;">
										<td style="color:#7D919F">付款时间</td>
										<td style="color:#7D919F">付款金额</td>
										<td style="color:#7D919F">付款账号</td>
										<td style="color:#7D919F">付款人</td> 
										<td style="color:#7D919F">状态</td>
										<td style="color:#7D919F">操作</td>
									</tr>
								</thead>
								<tbody>
									<volist name="info['paymentorder']" id="vo">
										<tr >
											<td><a href="{:U('finance/view', 't=paymentorder&id='.$vo['paymentorder_id'])}">{$vo.pay_time|date="Y-m-d",###}</a></td>
											<td><a href="{:U('finance/view', 't=paymentorder&id='.$vo['paymentorder_id'])}">{$vo.money}</a></td>
											<td><a href="{:U('finance/view', 't=paymentorder&id='.$vo['paymentorder_id'])}">{$vo.receipt_account}</a></td>
											<td><a class="role_info" href="javascript:void(0)" rel="{$vo['owner_role_id']}">{$vo['owner_name']}</a></td>
											<td class="check_badge">
												<if condition="$vo['status'] eq 1">
													已通过
												<elseif condition="$vo['status'] eq 2"/>
													已拒绝
												<else />
													待审核
												</if>
											</td>
											<td class="dropdown">
												<span class="dropdown-toggle fa-stack fa-lg" data-toggle="dropdown" style="cursor:pointer;height:3rem;color:#8FA1B2">
													<i class="fa fa-angle-down" style="margin-left:12px;margin-top:-3px;"></i>
												</span>
												<ul class="dropdown-menu">
													<li><a href="javascript:void(0);" rel="{$vo['paymentorder_id']}" class="not_rel_contacts" >删除</a></li>
													<li><a href="{:U('finance/edit',array('t'=>'paymentorder','id'=>$vo['paymentorder_id']))}">编辑</a></li>
												</ul>
											</td>
										</tr>
									</volist>
								</tbody>
							</table>
						</div>
					</div>
					<div style="clear:both;"></div>
				</div>
			</div>
		</div>
	</div>
</div>
<div style="display:none;" id="dialog-paymentorder" title="{:L('ADD paymentorder')}">
	<div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<div style="display:none;" id="dialog-role-info" title="{:L('DIALOG_USER_INFO')}">
	<div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<div style="display:none;" id="dialog-check-info" title="收款单审核">
	<form action="{:U('finance/check','t=paymentorder')}" method="post">
		<input id="dialog_order_id" name="paymentorder_id" type="hidden" value="{$id}" />
		<input name="t" type="hidden" value="paymentorder"/>
		<table class="table">
			<tr>
				<td>
					收款单号：<a href="javascript:;" target="_blank" id="dialog_check_order_no"></a>
					<br/>
					<br/>
					<textarea tabindex="0" style="width:400px;height:200px;" id="dialog_description" name="description" placeholder="填写理由(非必填)"></textarea>
				</td>
			</tr>
			<tr>
				<td style="text-align:center;">
					<button type="submit" name="submit" value="agree" class="btn btn-primary">同意</button> &nbsp; &nbsp;
					<button type="submit" name="submit" value="deny" class="btn btn-warning">拒绝</button>
				</td>
			</tr>
		</table>
	</form>
</div>
<script>
	var pm_heigth = window.screen.height * 0.57;
	$('#left-content').css('min-height',pm_heigth+'px');
	$('#right-content').css('min-height',pm_heigth+'px');
	$(".role_info").click(function(){
		$role_id = $(this).attr('rel');
		$('#dialog-role-info').dialog('open');
		$('#dialog-role-info').load('{:U("user/dialoginfo","id=")}'+$role_id);
	});
	$("#dialog-role-info").dialog({
		autoOpen: false,
		modal: true,
		width: 800,
		maxHeight:550,
		position: ["center",100]
	});
	$(".check_badge").hover(function(){
		$(this).find('.control').toggle();
	});
	$("#dialog-check-info").dialog({
		autoOpen: false,
		modal: true,
		width: 450,
		maxHeight: 400,
		position: ["center",100]
	});
	$("#add_paymentorder").click(function(){
		$('#dialog-paymentorder').dialog('open');
		$('#dialog-paymentorder').load('{:U("finance/adddialog","t=paymentorder&id=")}'+{$info['payables_id']});
	});
	$("#dialog-paymentorder").dialog({
		autoOpen: false,
		modal: true,
		width: 540,
		maxHeight: 600,
		position: ["center",100],
		buttons: {
			"确定": function () {
				$('#paymentorder_dialog').submit();
				$(this).dialog("close");
			},
			"取消": function () {
				$(this).dialog("close");
			}
		}
	});
	$(".checkbtn").click(function(){
		var order_id = $(this).attr('rel');
		var order_name = $(this).attr('rel2');
		$("#dialog_check_order_no").text(order_name);
		$("#dialog_check_order_no").attr('href', '{:U('finance/view','t=paymentorder&id=')}'+order_id);
		$("#dialog_order_id").val(order_id);
		$('#dialog-check-info').dialog('open');
		$("#dialog_description").focus();
	});
	//删除付款单
	$('.not_rel_contacts').click(function(){
		var paymentorder_id = $(this).attr('rel');
		if(paymentorder_id == 0){
			alert_crm('您没有选择任何付款单！');
			return false;
		}
		swal({
			title: "您确定要删除这条信息吗？",
   			text: "删除后将无法恢复，请谨慎操作！",
			type: "warning",   
			showCancelButton: true,   
			confirmButtonColor: "#DD6B55",   
			confirmButtonText: "是的，我要删除！",
	        cancelButtonText:'让我再考虑一下…',
	        closeOnConfirm:false,
	        closeOnCancel:false
		},
		function(isConfirm){
	        if (isConfirm) {
	        	$.ajax({
		            type:'post',
		            url: "{:U('finance/delete','t=paymentorder')}",
		            data: {id:paymentorder_id,t:'paymentorder'},
		            async: false,
		            success: function (data) {
						if (data.status == 1) {
							swal("删除成功！", "您已经永久删除了信息！", "success");
							location.reload();
						}else{
							swal({
								title: "操作失败！",
								text:data.info,
								type: "error"
							})
							return false;
						}
		            },
		            dataType: 'json'
		        });
	        } else {
	            swal("已取消","您取消了删除操作！","error");
	        }
	    });
	});
</script>